This page last changed on Feb 17, 2006 by [email protected].
Tag - formRemote
Description
Creates a form tag that uses a remote uri to execute an ajax call serializing the form elements falling back to a normal form submit if javascript is not supported.
Parameters
- url - The url to submit to, either a map contraining keys for the action,controller and id or string value
- action (optional) - The action to execute as a fallback, defaults to the url if non specified
- update (optional) - Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
- before (optional) - The javascript function to call before the remote function call
- after (optional) - The javascript function to call after the remote function call
- asynchronous (optional) - Whether to do the call asynchronously or not (defaults to true)
- method (optional) - The method to use the execute the call (defaults to "post")
Events
- onSuccess (optional) - The javascript function to call if successful
- onFailure (optional) - The javascript function to call if the call failed
- on_ERROR_CODE (optional) - The javascript function to call to handle specified error codes (eg on404="alert('not found!')")
- onUninitialized (optional) - The javascript function to call the a ajax engine failed to initialise
- onLoading (optional) - The javascript function to call when the remote function is loading the response
- onLoaded (optional) - The javascript function to call when the remote function is completed loading the response
- onComplete (optional) - The javascript function to call when the remote function is complete, including any updates
Examples
Example controller for an application called "shop":
class Book {
@Property defaultAction="list"
@Property list = { [ books: Book.list( params ) ] }
@Property show = { [ book : Book.get( params['id'] ) ] }
}
Example usages for above controller:
<g:formRemote on404="alert('not found!')" update="updateMe" action="show">
Login: <input name="login" type="text"></input>
</g:formRemote>
<div id="updateMe">this div is updated by the form</div>
|